<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>吕超英语退费计算器</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            max-width: 600px;
            margin: 50px auto;
            padding: 20px;
        }
        .calculator {
            background-color: #f8f9fa;
            padding: 30px;
            border-radius: 10px;
            box-shadow: 0 0 10px rgba(0,0,0,0.1);
        }
        .input-group {
            margin-bottom: 20px;
        }
        label {
            display: block;
            margin-bottom: 10px;
            font-weight: bold;
        }
        input {
            width: 100%;
            padding: 8px;
            font-size: 16px;
            border: 1px solid #ddd;
            border-radius: 4px;
            box-sizing: border-box;
        }
        button {
            background-color: #4CAF50;
            color: white;
            padding: 10px 20px;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 16px;
        }
        button:hover {
            background-color: #45a049;
        }
        #result {
            margin-top: 20px;
            font-size: 18px;
            font-weight: bold;
        }
    </style>
</head>
<body>
    <div class="calculator">
        <h2>吕超英语退费计算器（续费3个月专用）</h2>
        <div class="input-group">
            <label for="totalFee">续费费用（元）:</label>
            <input type="number" id="totalFee" min="0" value="1460" placeholder=请输入总费用数">
        </div>
        <div class="input-group">
            <label for="days">已使用天数（0-90）:</label>
            <input type="number" id="days" min="0" max="90" placeholder="请输入天数">
        </div>
        <button onclick="calculateRefund()">计算退费</button>
        <div id="result"></div>
    </div>

    <script>
        function calculateRefund() {
            // 获取输入值
            const totalFeeInput = document.getElementById('totalFee').value;
            const totalFee = totalFeeInput ? parseFloat(totalFeeInput) : 1460;
            const totalDays = 90;
            const a = parseInt(document.getElementById('days').value);

            // 验证输入有效性
            if (isNaN(a) || a < 0 || a > 90) {
                alert("请输入0到90之间的有效天数");
                return;
            }
            if (isNaN(totalFee) || totalFee <= 0) {
                alert("请输入有效的正数金额");
                return;
            }

            // 计算退费
            let refund;
            if (a <= 30) {
                refund = totalFee / totalDays * (totalDays - a);
            } else {
                refund = totalFee * 0.8 / totalDays * (totalDays - a);
            }

            // 显示结果
            const resultElement = document.getElementById('result');
            resultElement.innerHTML = `
                续费费用：${totalFee.toFixed(2)} 元<br>
                应退天数：${totalDays - a}天<br>
                计算折扣：${a <= 30 ? '全价' : '八折'}<br>
                折扣说明：已使用30天内（含30天）退款不扣费用，为：全价。已使用30天以上退款扣除20%费用，为：八折。<br>
                <h3 style="color: #d32f2f;">应退金额：${refund.toFixed(2)} 元</h3>
            `;
        }
    </script>
</body>
</html>